package com.edu.spring.ioc.bean;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

@Component
@Data
// 1.classpath:xxx :从自己的项目类路径下找
// 2.classpath*:xxx:从所有包的类路径下找
@PropertySource("classpath:cat.properties")
public class Cat {
    @Value("${cat.name}")
    private String name;

    @Value("${cat.age:20}") // :20 取不到值时的默认值
    private int age;
}
